package com.c2.service.impl;

import com.c2.entity.EbProductCategory;
import com.c2.mapper.ProductCategoryMapper;
import com.c2.service.ProductCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author Stars Lee
 * @date 2020/9/16 - 15:39
 */
@Service
public class ProductCategoryServiceImpl implements ProductCategoryService {
    @Autowired
    private ProductCategoryMapper productCategoryMapper;

    @Override
    public List<EbProductCategory> bigClassList(){
        return productCategoryMapper.findBigClass();
    }

    @Override
    public List<EbProductCategory> smallClassList(Integer parentId){
        return productCategoryMapper.findSmallClass(parentId);
    }

    @Override
    public List<EbProductCategory> bigClassListByPage(Integer from,Integer pageSize){
        return productCategoryMapper.findBigClassByPage((from-1)*pageSize,pageSize);
    }

    @Override
    public List<EbProductCategory> smallClassListByPage(Integer parentId,Integer from,Integer pageSize){
        return productCategoryMapper.findSmallClassByPage(parentId,(from-1)*pageSize,pageSize);
    }
//    @Override
//    public List<EbProductCategory> listByPage(Integer page,Integer pageSize){
//        Integer from=(page-1)*pageSize;
//        return productCategoryMapper.findByPage(from,pageSize);
//    }

//    @Override
//    public Integer findMaxPage(Integer pageSize){
//        return productCategoryMapper.findAllPage(pageSize);
//    }
    @Override
    public Integer findBigAllPage(Integer pageSize){
        return productCategoryMapper.findBigAllPage(pageSize);
    }

    @Override
    public Integer findSmallAllPage(Integer parentId,Integer pageSize){
        return productCategoryMapper.findSmallAllPage(parentId,pageSize);
    }

    @Override
    public Integer toSaveProductCategory(EbProductCategory ebProductCategory){
        return productCategoryMapper.insertSave1(ebProductCategory);
    }

    @Override
    public Integer toDeleteProductCategory(Integer epcId){
        return productCategoryMapper.deleteByPrimary(epcId);
    }

    @Override
    public List<EbProductCategory> selectByCondition(Integer epcId){
        return productCategoryMapper.findByPrimary(epcId);
    }
    @Override
    public Integer toUpdateProductCategory(EbProductCategory ebProductCategory){
        return productCategoryMapper.updateByPrimary(ebProductCategory);
    }
}
